//#Author:bin
// -*- charset = utf-8 -*-
// @time:2022/8/25 14:39
// @Author:bfl91
// @file : school.js
// @Software:WebStorm
import {getCategories} from "@/api/getfun";
export default {
    namespaced:true,
    state:{
        classList:[],//分类数组,
        itemLIst:[],//展示的数据,
        index:0,
    },
    mutations:{
        setclass(state,list){
            state.classList=list;
        },
        setIndex(state,index){
            state.index=index;
        }
    },
    getters:{
        itemLIst(state){
                let list=state.classList;
                let arr=[]
                list[state.index].children.forEach((item,index)=>{
                    if(item.children){
                        for(var i=0;i<item.children.length;i++){
                            arr.push(item.children[i])
                        }
                    }
                })
            return arr
        }
    },
    actions:{
        getclassList(contxt){
            getCategories().then(res=>{
                let {message}=res.data
                contxt.commit('setclass',message)
            })
        }
    }
}